use std::collections::HashSet;

struct Solution {}

fn main() {}

impl Solution {
    pub fn single_number(nums: Vec<i32>) -> i32 {
        let mut number_set = HashSet::new();
        for number in nums.iter() {
            if !number_set.contains(number) {
                number_set.insert(number);
            } else {
                number_set.remove(number);
            }
        }
        return **number_set.iter().nth(0).unwrap();
    }
}